#include "Rp2PixelShader.h"

using namespace Rp2;

RP2_IMPLEMENT_RTTI(Rp2, PixelShader, Shader);
RP2_IMPLEMENT_DEFAULT_NAME_ID(PixelShader, Shader);

//---------------------------------------------------------------------------------------------------
PixelShader::PixelShader(const std::string& rkShaderName)
	:
	Shader(rkShaderName)
{
	m_spkProgram = Catalog<PixelProgram>::GetActive()->Find(rkShaderName);
	if (!m_spkProgram)
	{
        // Use the default pixel program when the requested program
        // cannot be found.
		m_spkProgram = Catalog<PixelProgram>::GetActive()->Find("Default");

        // In release builds, if the default pixel program cannot be found,
        // you probably have placed the shader programs in a place that
        // is not stored in the System directory lists.
        assert(m_spkProgram);
	}

	if (m_spkProgram)
	{

		OnLoadProgram();
	}
}
//---------------------------------------------------------------------------------------------------
PixelShader::PixelShader()
{
}
//---------------------------------------------------------------------------------------------------
PixelShader::~PixelShader()
{
}
//---------------------------------------------------------------------------------------------------
void PixelShader::SetShader(const std::string& rkShaderName)
{
	m_kShaderName = rkShaderName;

	m_spkProgram = Catalog<PixelProgram>::GetActive()->Find(rkShaderName);
	if (!m_spkProgram)
	{
        // Use the default pixel program when the requested program
        // cannot be found.
		m_spkProgram = Catalog<PixelProgram>::GetActive()->Find("Default");

        // In release builds, if the default pixel program cannot be found,
        // you probably have placed the shader programs in a place that
        // is not stored in the System directory lists.
        assert(m_spkProgram);
	}

	if (m_spkProgram)
	{
		OnLoadProgram();
	}
}
//---------------------------------------------------------------------------------------------------
PixelProgram* PixelShader::GetProgram() const
{
	return StaticCast<PixelProgram>(m_spkProgram);
}
//---------------------------------------------------------------------------------------------------